package com.ambow.core.controller;


import com.ambow.core.po.DqDeveloper;
import com.ambow.core.po.DqGame;
import com.ambow.core.service.DqDeveloperService;
import com.dq.gamepropaganda.common.R;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 开发者表 前端控制器
 * </p>
 *
 * @author dq
 * @since 2022-09-05
 */
//跨域
@CrossOrigin
@RestController
@RequestMapping("/front/dqDeveloper")
public class DqDeveloperController {

    @Autowired
    private DqDeveloperService dqDeveloperService;

    //id找单个开发商
    @GetMapping("/findDeveloperById/{roleId}")
    @ApiOperation("根据id查开发商")
    public R findGameById(@PathVariable Integer roleId){
        DqDeveloper developer = dqDeveloperService.getById(roleId);
        return R.ok().message("ok").data("developer",developer);
    }

    //list
    @GetMapping("/list")
    @ApiOperation("开发商list")
    public R listAll(){

        List<DqDeveloper> list = dqDeveloperService.list();
        return R.ok().message("ok").data("list",list);
    }
    //审核状态检查
    //dqDeveloperService.findDeveloperStaticByid();

    @PostMapping("/completeInformation")
    @ApiOperation("修改信息")
    public R completeInformation(DqDeveloper developer){
        //重置审核状态

        developer.setDeveloperStatic(0);
        boolean b = dqDeveloperService.update(developer,null);
        if (b){
            return R.ok().message("成功,请等待审核,审核结果会在邮件通知您");
        }else {
            return R.error();
        }
    }

    //@PostMapping("/updateDqDeveloper")
//    @ApiOperation("修改信息")
//    public R updateDqDeveloper(DqDeveloper developer){
//        //修改信息自动填充
//        boolean b = dqDeveloperService.update(developer,null);
//        if (b){
//            return R.ok().message("修改成功");
//        }else {
//            return R.error().message("修改失败");
//        }
//
//
//    }
    
}

